import traceback

from fastapi import APIRouter, WebSocket

from llm import dashscope_stream
from common.logger import logger

router = APIRouter(prefix='/ws', tags=['问诊'])

@router.websocket('/imp')
async def websocket_endpoint(websocket: WebSocket):
    try:
        await dashscope_stream.dashscope_stream_api(websocket)
    except Exception as e:
        logger.error(f"发生未知错误: {e}")
        traceback.print_exc()


@router.get('/hello')
def hello():
    return 'hello world'